#ifndef LOGINWIDGET_H
#define LOGINWIDGET_H

#include "logindialog.h"
#include <QWidget>
#include "chatwindow.h"
#include <QListWidgetItem>

class CToolTip;

namespace Ui {
class LoginWidget;
}

class LoginWidget : public QWidget
{
    Q_OBJECT

public:
    static int ID;
    explicit LoginWidget(QWidget *parent = 0);
    ~LoginWidget();

private slots:
    void on_quit_clicked();
    void conChat(QListWidgetItem*);

private:
    Ui::LoginWidget *ui;
    QSqlDatabase database;
    CToolTip *ctoolTip;

    ChatWindow *chatWindow;

    bool tableFlag;

    int usr_id;
    QString usr_passwd;
    QString usr_name;
    QString usr_email;
    int usr_history;
    bool matchFlag;

    QString select_table = "select tbl_name name from sqlite_master where type = 'table'";
    QString create_sql = "create table user (chatid int primary key, passwd varchar(30), name varchar(30), email varchar(30), history int)";
    QString select_max_sql = "select max(chatid) from user";
    QString insert_sql = "insert into user values (?, ?, ?, ? ?)";
    //QString update_sql = "update user set name = :name where chatid = :chatid";
    QString select_sql = "select name from user";
    //QString select_all_sql = "select * from user";
    //QString delete_sql = "delete from user where chatid = ?";
    //QString clear_sql = "delete from user";

    QString select_nameInfo = "selcet * from user where name=";
};

#endif // LOGINWIDGET_H
